package com.taobao.yugong.translator;

import com.taobao.yugong.common.db.meta.ColumnMeta;
import com.taobao.yugong.common.db.meta.ColumnValue;
import com.taobao.yugong.common.model.record.Record;
import org.springframework.jdbc.core.JdbcTemplate;

import javax.sql.DataSource;
import java.sql.Types;
import java.util.Objects;

public class EtPacklistDataTranslator extends BackTableDataTranslator implements DataTranslator {


    @Override
    public String translatorTable() {
        return "et_packlist_1";
    }

    @Override
    public boolean translator(DataSource sourceDs, Record record) {
        JdbcTemplate jdbcTemplate = new JdbcTemplate(sourceDs);
        return false;
    }

    @Override
    public boolean translator(Record record) {

        ColumnValue columnValue = record.getColumnByName("STDATASTATUS");
        if (null != columnValue) {
            String v = (String) columnValue.getValue();
            if (Objects.equals("D", v)) {
                return false;
            }
        }

        record.removeColumnByName("batch", true);

        ColumnMeta gmtMoveMeta = new ColumnMeta("invoice_no", Types.VARCHAR);
        ColumnValue gmtMoveColumn = new ColumnValue(gmtMoveMeta, "test1111");
        gmtMoveColumn.setCheck(false);
        record.addColumn(gmtMoveColumn);

        return super.translator(record);
    }

}
